version 16
set more off
set matsize 11000
 
***************************************************************************************************
*THIS FILE PRODUCES FIGURE II OF SLEMROD-REHMAN-WASEEM-2020, RESTAT
***************************************************************************************************
 
/* PRELIMINARIES */
 
use							"$project_data\ITRM_Dislo_Unique_SelfEmployed.dta", clear
keep                    regno year TaxPaid it_office_id ind location_code name_count_v2
bys                     regno:g nreturns=_N
keep                    if nreturns==10
g                       logtaxpaid=log(TaxPaid)
bys                     regno:egen namefreq=min(name_count_v2)
forvalues               y=2007/2015 {
g                         y_`y'=(year==`y')
}

/* PANLE A: (FREQ<=10) */

g                       treat=namefreq<=10
forvalues               y=2007/2015 {
g                          treat_`y'=(treat==1 & year==`y')
}
qui                     areg logtaxpaid y_* treat_2*, absorb(regno) cluster(regno)
g                       betahats=0
g                       cil=0
g                       cih=0
forvalue                y=2007/2015 {
                          cap replace betahats=_b[treat_`y'] if year==`y' 
                          cap replace cil=_b[treat_`y']-1.96*_se[treat_`y'] if year==`y'
                          cap replace cih=_b[treat_`y']+1.96*_se[treat_`y'] if year==`y'
}
bys                     year treat:g index=_n
#d                      ;
twoway                  (rarea cil cih year if year>2006 & index==1,sort color(gs14))
                        (connected  betahats year if year>2006 & index==1,sort lwidth(thick) lcolor(red) mcolor(red) msize(large)  msymbol(S)),
                        xtitle("Tax Year") xscale(titlegap(*10))
                        xlabel(2007(1)2015)
                        yscale(r(0))  yscale(titlegap(*10)) ytitle("Difference-in-differences Coefficient") ylabel(-0.2(0.1)0.2)
                        xline(2011.5, lpatter(dash) lcolor(green))
                        legend(region(style(none)) label(1 "95% Confidence Interval") label(2 "Coefficient") order(2 1))
                        graphregion(fcolor(white) style(none) color(white) margin(0 2 0 0)) bgcolor(white);
graph                   export "$project_output\EventStudy_TaxPaid_lessthan10.eps", replace;
#d                      cr

/* PANEL B: (ABOVE VS. BELOW MEDIAN) */
 
drop                    treat* index betahats cil cih
qui                     sum namefreq, d
g                       treat=namefreq<=r(p50)
forvalues               y=2007/2015 {
g                         treat_`y'=(treat==1 & year==`y')
}
qui                     areg logtaxpaid y_* treat_2*, absorb(regno) cluster(regno)
g                       betahats=0
g                        cil=0
g                        cih=0
forvalue                y=2007/2015 {
                          cap replace betahats=_b[treat_`y'] if year==`y' 
                          cap replace cil=_b[treat_`y']-1.96*_se[treat_`y'] if year==`y'
                          cap replace cih=_b[treat_`y']+1.96*_se[treat_`y'] if year==`y'
}
bys                     year treat:g index=_n
#d                      ;
twoway                  (rarea cil cih year if year>2006 & index==1,sort color(gs14))
                        (connected  betahats year if year>2006 & index==1,sort lwidth(thick) lcolor(red) mcolor(red) msize(large)  msymbol(S)),
                        xtitle("Tax Year") xscale(titlegap(*10))
                        xlabel(2007(1)2015)
                        yscale(r(0))  yscale(titlegap(*10)) ytitle("Difference-in-differences Coefficient") ylabel(-0.2(0.1)0.2)
                        xline(2011.5, lpatter(dash) lcolor(green))
                        legend(region(style(none)) label(1 "95% Confidence Interval") label(2 "Coefficient") order(2 1))
                        graphregion(fcolor(white) style(none) color(white) margin(0 2 0 0)) bgcolor(white);
graph                   export "$project_output\EventStudy_TaxPaid_median.eps", replace;
#d                              cr

/* PANEL C: (BOTTOM VS. TOP QUARTILE) */
 
drop                    treat* index betahats cil cih
qui                     sum namefreq, d
g                       treat=namefreq<=r(p25)
drop                    if namefreq>r(p25) & namefreq<=r(p75)
forvalues               y=2007/2015 {
g                          treat_`y'=(treat==1 & year==`y')
}
qui                     areg logtaxpaid y_* treat_2*, absorb(regno) cluster(regno)
g                       betahats=0
g                       cil=0
g                       cih=0
forvalue                y=2007/2015 {
                          cap replace betahats=_b[treat_`y'] if year==`y' 
                          cap replace cil=_b[treat_`y']-1.96*_se[treat_`y'] if year==`y'
                          cap replace cih=_b[treat_`y']+1.96*_se[treat_`y'] if year==`y'
}
bys                     year treat:g index=_n
#d                      ;
twoway                  (rarea cil cih year if year>2006 & index==1,sort color(gs14))
                        (connected  betahats year if year>2006 & index==1,sort lwidth(thick) lcolor(red) mcolor(red) msize(large)  msymbol(S)),
                        xtitle("Tax Year") xscale(titlegap(*10))
                        xlabel(2007(1)2015)
                        yscale(r(0))  yscale(titlegap(*10)) ytitle("Difference-in-differences Coefficient") ylabel(-0.2(0.1)0.2)
                        xline(2011.5, lpatter(dash) lcolor(green))
                        legend(region(style(none)) label(1 "95% Confidence Interval") label(2 "Coefficient") order(2 1))
                        graphregion(fcolor(white) style(none) color(white) margin(0 2 0 0)) bgcolor(white);
graph                   export "$project_output\EventStudy_TaxPaid_Quartile.eps", replace;
#d                      cr

/* PANEL D: (BOTTOM VS. TOP DECILE) */

drop                    treat* index betahats cil cih
qui                     sum namefreq, d
g                       treat=namefreq<=r(p10)
drop                    if namefreq>r(p10) & namefreq<=r(p90)
forvalues               y=2007/2015 {
g                          treat_`y'=(treat==1 & year==`y')
}

qui                     areg logtaxpaid y_* treat_2*, absorb(regno) cluster(regno)
g                         betahats=0
g                         cil=0
g                         cih=0
forvalue                y=2007/2015 {
                          cap replace betahats=_b[treat_`y'] if year==`y' 
                          cap replace cil=_b[treat_`y']-1.96*_se[treat_`y'] if year==`y'
                          cap replace cih=_b[treat_`y']+1.96*_se[treat_`y'] if year==`y'
}
bys                    	year treat:g index=_n
#d                      ;
twoway                  (rarea cil cih year if year>2006 & index==1,sort color(gs14))
                        (connected  betahats year if year>2006 & index==1,sort lwidth(thick) lcolor(red) mcolor(red) msize(large)  msymbol(S)),
                        xtitle("Tax Year") xscale(titlegap(*10))
                        xlabel(2007(1)2015)
                        yscale(r(0))  yscale(titlegap(*10)) ytitle("Difference-in-differences Coefficient") ylabel(-0.2(0.1)0.2)
                        xline(2011.5, lpatter(dash) lcolor(green))
                        legend(region(style(none)) label(1 "95% Confidence Interval") label(2 "Coefficient") order(2 1))
                        graphregion(fcolor(white) style(none) color(white) margin(0 2 0 0)) bgcolor(white);
graph                   export "$project_output\EventStudy_TaxPaid_Decile.eps", replace;
#d                      cr
